<template>
	<view class="content">
		<view class="swiper-wrap">
			<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
				<swiper-item>
					<image class="swiper-item" src="../../static/image/1.jpg" mode="scaleToFill"></image>
				</swiper-item>
				<swiper-item>
					<image class="swiper-item" src="../../static/image/6.jpg" mode="scaleToFill"></image>
				</swiper-item>
			</swiper>
		</view>
		
		<view class="content-wrap">
			<view class="part">
				<view class="elem-quote">
					业务办理
				</view>
				<view class="sub-part">
					<view class="sub-item"  @click="goTo('../dengji2/index')">
						<view class="title-part">
							<text class="title">备案登记</text>
							<text class="subtitle">异地就医备案</text>
						</view>
						<view class="img-part">
							<!-- aspectFit -->
							<image class="img" src="/static/image/dengji.png" mode="widthFix"></image>
						</view>
					</view>
					<view class="padding-10"></view>
					<navigator  class="sub-item"  url="../dingdian/dingdian" >
						<view class="title-part">
							<text class="title">定点查询</text>
							<text class="subtitle">定点机构信息查询</text>
						</view>
						<view class="img-part">
							<image  class="img"  src="/static/image/chaxun.png" mode="widthFix"></image>
						</view>
					</navigator>
				</view>
			</view>
			<view class="part">
				<view class="elem-quote">
				    政策新闻
				</view>
				<uni-list v-if="newsArr.length" class="my-list">
					<uni-list-item v-for="(news,newsIndex) in newsArr" :key="newsIndex" :title="news.HEADLINE" :note="news.PUBDATE|formaterDay"  @click="gotoDetails(news)"></uni-list-item>
				</uni-list>
			</view>
		</view>
	</view>
</template>

<script>
	import uniList from '@/components/uni-list/uni-list.vue'
	import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
	export default {
		components: {uniList,uniListItem},
		filters:{
			formaterDay(val){
				return val.substring(0,10);
			}
		},
		data() {
			return {
				isLogin:false,
				isFillInfo:false,
				indicatorDots: true,
				autoplay:true,
				interval:2000,
				duration:800,
				newsArr:[]
			}
		},
	
		
		onLoad() {

		},
		methods: {
			goTo(url) {
					if (!this.isLogin ) {
						var that = this;
						uni.showToast({
							title: '请登录',
							icon: 'none',
							duration: 2000,
							success: function() {
								if(that.$common.sys.toSSOLogin){
									setTimeout(function() {
										window.location.assign(that.$common.sys.ssoUrl+"="+that.$common.sys.redirectUri);
									}, 2000)
									
								}else{
									setTimeout(function() {
										uni.navigateTo({
											url: '../registerLogin/registerLogin'
										})
									}, 2000)
								}
	
							}
						});
						return false;
					}
					if(!this.isFillInfo){
						uni.showToast({
							title: '请完善个人参保信息',
							icon: 'none',
							duration: 2000,
							success: function() {
								setTimeout(function() {
									uni.navigateTo({
										url: "../fillInfo/fillInfo",
									})
								}, 2000)
						
							}
						});
						return false;
					}
			        
					uni.navigateTo({
						url: url
					})
				},
			
			gotoDetails(data){
				uni.navigateTo({
					url:"../newsDetails/newsDetails?current=" + JSON.stringify(data)
				})
			}
		},
		created(){
			var self = this;
			this.$request('S1014',{PAGESIZE:5,PAGENUM:1},'POST',function(res){
				console.log('新闻',res)
				
				if(res.data.CODE==0){
					self.newsArr = res.data.DATA;
				}
			})
		},
		onShow(){
			this.isLogin = uni.getStorageSync('isLogin');
			this.userInfo = uni.getStorageSync('userInfo');
			this.isFillInfo =  this.$common.isFillInfo(this.userInfo);
		}
	}
</script>

<style>
	.swiper{
		height: 350upx!important;
	}
	.swiper-item{
		width: 100vw;
		height: 350upx!important;
	} 
	.part{
		margin: 20upx;
	}
	.elem-quote{
		margin-bottom: 20upx;
		padding: 18upx;
		line-height: 22px;
		text-align: left;
		font-size: 14px;
		border-left: 5px solid #3366cc;
		border-radius: 0 2px 2px 0;
		background-color: #f2f2f2;
	}
	.sub-part{
		display: flex;
		height: 180upx;
		/* justify-content: space-between; */
		flex-wrap: nowrap;
		
	}
	.sub-part .sub-item{
		display: flex;
		justify-content: center;
		flex-grow: 1;
		flex-shrink: 1;
		align-items: center;
	}
	.sub-part .sub-item .title-part .title{
		display: block;
		font-size: 20px;
		line-height: 26px;
		color: #3399ff;
	}
	.sub-part .sub-item .title-part .subtitle{
	    font-size: 12px;
		color: #999;
	}
	.padding-10{
		width: 10upx;
		height: 100%;
	}
	.img-part .img{
		width: 130upx;
		margin-left: 15upx;
	}
</style>
